﻿using System;
using System.Threading.Tasks;
using SilverCrmSoap.CrmSdk;


namespace Linq2Crm.Request.SpecificRequest
{
	public sealed class WhoAmIRequestWrapper : RequestBase
	{
		private WhoAmIRequestWrapper():base(null)
		{}		

		public Action<WhoAmIResponseWrapper> Callback { get; set; }

		internal OrganizationRequest WhoAmIRequest
		{
			get
			{
				return new OrganizationRequest
				{
					RequestName = "WhoAmI"
				};
			}			
		}

		#region Overrides of RequestBase
		internal override void Execute()
		{
			DomainObjectContext.Instance.ExecuteWhoAmIRequest(this);
		}

		internal override async Task<ResponseBase> ExecuteAsync()
		{
			var reponse = await DomainObjectContext.Instance.ExecuteWhoAmIRequestAsync(this);
			return reponse;
		}

		#endregion

		public static WhoAmIRequestWrapper Create()
		{
			return new WhoAmIRequestWrapper();
		}
	}
}